<?php

namespace Acme\StoreBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

use Doctrine\Common\Collections\ArrayCollection;

/**
 * Acme\StoreBundle\Entity\User
 * 
 * @ORM\Table(name="user")
 * @ORM\Entity(repositoryClass="Acme\StoreBundle\Repository\UserRepository") 
 */
class User
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     * 
     * @var integer $id
     */
    private $id;

    /**
     * @var string $username
     */
    private $username;

    /**
     * @var string $password
     */
    private $password;

    /**
     * @ORM\ManyToMany(targetEntity="UGroup") 
     * @ORM\OrderBy({"name" = "ASC"})    
     */
    private $groups;
    
    /**
     * @ORM\OneToOne(targetEntity="Shipping")    
     * @ORM\JoinColumn(name="shipping_id", referencedColumnName="id")       
     */
    private $shipping;
    
    /**
     * @ORM\ManyToOne(targetEntity="Address")
     * @ORM\JoinColumn(name="address_id", referencedColumnName="id")
     */
    private $address;
    
    // Many-To-Many, Self-Referencing
    /**
     * @ORM\ManyToMany(targetEntity="User", mappedBy="myFriends")
     */
    private $friendsWithMe;
    
    /**
     * @ORM\ManyToMany(targetEntity="User", inversedBy="friendsWithMe")
     * @ORM\JoinTable(name="friends",
     *      joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")},
     *      inverseJoinColumns={@ORM\JoinColumn(name="friend_user_id", referencedColumnName="id")}
     *      )     
     */
    private $myFriends;    
    
    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set username
     *
     * @param string $username
     */
    public function setUsername($username)
    {
        $this->username = $username;
    }

    /**
     * Get username
     *
     * @return string 
     */
    public function getUsername()
    {
        return $this->username;
    }

    /**
     * Set password
     *
     * @param string $password
     */
    public function setPassword($password)
    {
        $this->password = $password;
    }

    /**
     * Get password
     *
     * @return string 
     */
    public function getPassword()
    {
        return $this->password;
    }
    
    public function __construct()
    {
        $this->groups = new ArrayCollection();
        
        $this->friendsWithMe = new ArrayCollection();
        $this->myFriends = new ArrayCollection();
    }
    
    
    /**
     * Set shipping
     *
     * @param Acme\StoreBundle\Entity\Shipping $shipping
     */
    public function setShipping(\Acme\StoreBundle\Entity\Shipping $shipping)
    {
        $this->shipping = $shipping;
    }

    /**
     * Get shipping
     *
     * @return Acme\StoreBundle\Entity\Shipping 
     */
    public function getShipping()
    {
        return $this->shipping;
    }
    /**
     * @var integer $shipping_id
     */
    private $shipping_id;


    /**
     * Set shipping_id
     *
     * @param integer $shippingId
     */
    public function setShippingId($shippingId)
    {
        $this->shipping_id = $shippingId;
    }

    /**
     * Get shipping_id
     *
     * @return integer 
     */
    public function getShippingId()
    {
        return $this->shipping_id;
    }
    
  

    /**
     * Add groups
     *
     * @param Acme\StoreBundle\Entity\UGroup $groups
     */
    public function addUGroup(\Acme\StoreBundle\Entity\UGroup $groups)
    {
        $this->groups[] = $groups;
    }

    /**
     * Get groups
     *
     * @return Doctrine\Common\Collections\Collection 
     */
    public function getGroups()
    {
        return $this->groups;
    }

    /**
     * Set address
     *
     * @param Acme\StoreBundle\Entity\Address $address
     */
    public function setAddress(\Acme\StoreBundle\Entity\Address $address)
    {
        $this->address = $address;
    }

    /**
     * Get address
     *
     * @return Acme\StoreBundle\Entity\Address 
     */
    public function getAddress()
    {
        return $this->address;
    }
}